package com.smarthealthcare.followup.service.impl;

import java.util.List;

import com.smarthealthcare.domain.Register;
import com.smarthealthcare.mapper.RegisterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.smarthealthcare.followup.mapper.FollowupMapper;
import com.smarthealthcare.followup.domain.Followup;
import com.smarthealthcare.followup.service.IFollowupService;

/**
 * followupService业务层处理
 * 
 * @author ruoyi
 * @date 2024-11-22
 */
@Service
public class FollowupServiceImpl implements IFollowupService 
{
    @Autowired
    private FollowupMapper followupMapper;
    @Autowired
    private RegisterMapper registerMapper;

    /**
     * 查询followup
     * 
     * @param id followup主键
     * @return followup
     */
    @Override
    public Followup selectFollowupById(Long id)
    {
        return followupMapper.selectFollowupById(id);
    }

    /**
     * 查询followup列表
     * 
     * @param followup followup
     * @return followup
     */
    @Override
    public List<Followup> selectFollowupList(Followup followup)
    {
        List<Followup> followups = followupMapper.selectFollowupList(followup);
        for (Followup f : followups){
            Long patientId = f.getPatientId();
            Register register = registerMapper.selectRegisterById(patientId);
            f.setRegister(register);
        }
        return followups;
    }

    /**
     * 新增followup
     * 
     * @param followup followup
     * @return 结果
     */
    @Override
    public int insertFollowup(Followup followup)
    {
        return followupMapper.insertFollowup(followup);
    }

    /**
     * 修改followup
     * 
     * @param followup followup
     * @return 结果
     */
    @Override
    public int updateFollowup(Followup followup)
    {
        return followupMapper.updateFollowup(followup);
    }

    /**
     * 批量删除followup
     * 
     * @param ids 需要删除的followup主键
     * @return 结果
     */
    @Override
    public int deleteFollowupByIds(Long[] ids)
    {
        return followupMapper.deleteFollowupByIds(ids);
    }

    /**
     * 删除followup信息
     * 
     * @param id followup主键
     * @return 结果
     */
    @Override
    public int deleteFollowupById(Long id)
    {
        return followupMapper.deleteFollowupById(id);
    }
}
